<?php

/**
 * This is the model class for table "{{transfer_user}}".
 *
 * The followings are the available columns in table '{{transfer_user}}':
 * @property integer $id
 * @property integer $transfer_id
 * @property string $username
 * @property string $c_username
 * @property string $unique_id
 * @property string $entry_point
 */
class TransferUser extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return TransferUser the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{transfer_user}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('transfer_id, username, c_username, unique_id, entry_point', 'required'),
			array('transfer_id', 'numerical', 'integerOnly'=>true),
			array('username, c_username, unique_id', 'length', 'max'=>32),
			array('entry_point', 'length', 'max'=>64),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, transfer_id, username, c_username, unique_id, entry_point, position ,old_attr_id,new_attr_id,old_L,old_M,old_B,new_L,new_M,new_B', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'user'=>array(self::BELONGS_TO, 'Transfer', 'transfer_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'transfer_id' => 'Transfer',
			'username' => 'Username',
			'c_username' => 'C Username',
			'unique_id' => 'Unique',
			'entry_point' => 'Entry Point',
			'position' => 'Position',
			'attribute' => 'Attribute',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('transfer_id',$this->transfer_id);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('c_username',$this->c_username,true);
		$criteria->compare('unique_id',$this->unique_id,true);
		$criteria->compare('position',$this->position,true);
		$criteria->compare('attribute',$this->attribute,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}